package com.roc.web.action.windcontroll;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class ExportMtableSearchCondition extends BaseSearchCondition{
	
	private static final long serialVersionUID = 1L;
	
	private String minDate;
	private String maxDate;
	private String mchtCd;

	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		
		if(Constance.isNotEmpty(minDate)){
         	filedBeanList.add(new WhereHQLFieldBean("t.Rec_Crt_Ts >= to_date('"+minDate.trim()+"', 'yyyymmdd')"));
       	}
		
		if(Constance.isNotEmpty(maxDate)){
			filedBeanList.add(new WhereHQLFieldBean("t.Rec_Crt_Ts < to_date('"+maxDate.trim()+"', 'yyyymmdd' )+ 1 "));
		}
		
		if(Constance.isNotEmpty(mchtCd)){
			filedBeanList.add(new WhereHQLFieldBean("t.mcht_cd", mchtCd.trim(), "=", false));
		}
		
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		String sql = "select count(*) from tbl_mcht_inf t where t.status='01' and length(t.uc_bc_cd_32)=8 ";
		return sql;
	}

	@Override
	protected String getSearchHQL() {
		String sql = "select 'I', t.mcht_cd, t.name, t.name_busi,'0848500000',substr(t.uc_bc_cd_32,5,4), t.up_mcc_cd, "
				+ "t.status,t.busi_lice_no, t.reg_addr, t.certif,t.certif_type, t.certif_no, t.contact_name, "
				+ "t.reg_addr a, t.contact_phoneno, t.BILLINGTYPE, t.BILLINGLEVEL "
				+ "from tbl_mcht_inf t where t.status='01' and length(t.uc_bc_cd_32)=8 ";
		return sql;
	}

	@Override
	protected String getOrderPartOfHQL() {
		return "order by t.mcht_cd";
	}

	public String getMchtCd() {
		return mchtCd;
	}

	public void setMchtCd(String mchtCd) {
		this.mchtCd = mchtCd;
	}

	public String getMinDate() {
		return minDate;
	}

	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	public String getMaxDate() {
		return maxDate;
	}

	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}
	
}
